// pages/wuliurongqiguanli/nav_check_gzcbl/check_gzcbl.js
const mybehavior = require("../../../behaviors/requests")
const baseUrl = "https://logisticsengineering.gree.com/container_manage_api/container_manage/"
Page({

    /**
     * 页面的初始数据
     */
    behaviors: [mybehavior],
    data: {
        config_obj: {
            举报后待责任单位确认: ["责任单位已确认，待整改", "待公司管理员确定责任单位", "完结-责任单位已确认，作为月度考评数据",],//1.确定（是/否整改）2.申诉
            公司管理员判定所属责任单位待责任单位确认: ["责任单位已确认，待整改", "完结-责任单位已确认，作为月度考评数据",],//
            待公司管理员确定责任单位: ["待举报人修正数据或取消", "公司管理员判定所属责任单位，待责任单位确认"],
            责任单位已确认待整改: ["第1次整改完成，待举报人确认", "完结-整改未完成，作为月度考评数据"],//1，报完工2.未完成
            第1次整改完成待举报人确认: ["第1次整改完成，举报人不认可，待重新整改", "待公司管理员确认是否考核"],//1.驳回 2.完工
            第1次整改完成举报人不认可待重新整改: ["第1次整改结果有争议，待公司管理员判定", "责任单位已确认，待第2次整改"],
            第2次整改完成待举报人确认: ["待公司管理员确认是否考核"],
            第1次整改结果有争议待公司管理员判定: ["完结-管理员认定考核", "完结-管理员取消考核"],
            待公司管理员确认是否考核: ["完结-管理员认定考核", "完结-管理员取消考核"],
            责任单位已确认待第2次整改: ["第2次整改完成，待举报人确认", "完结-整改未完成，作为月度考评数据"],
            待举报人修正数据或取消: ["完结-举报人已取消", "举报后，待责任单位确认", "完结-自动取消"]
        },
        config_obj_: {
            举报后待责任单位确认: ["确认", "申诉"],//1.确定（是/否整改）2.申诉
            公司管理员判定所属责任单位待责任单位确认: ["确定"],//1.责任单位已确认，待整改2否整改（完结-责任单位已确认，作为月度考评数据）
            待公司管理员确定责任单位: ["同意申诉", "不同意申诉"],//1.待举报人修正数据或取消2.公司管理员判定所属责任单位，待责任单位确认
            责任单位已确认待整改: ["整改报完工", "未完成整改"],//整改报完工.未完成整改
            第1次整改完成待举报人确认: ["驳回", "完结"],//1.驳回 2.完结
            第1次整改完成举报人不认可待重新整改: ["申诉", "确认"],//1.反驳2.二次确认
            第2次整改完成待举报人确认: ["确认"],//确定
            第1次整改结果有争议待公司管理员判定: ["认定考核", "取消考核"],//1.认定考核2.取消考核
            待公司管理员确认是否考核: ["认定考核", "取消考核"],//1.认定考核2.取消考核
            责任单位已确认待第2次整改: ["整改报完工", "未完成整改"],
            待举报人修正数据或取消: ["取消举报", "确认举报"]//"完结-举报人已取消","举报后，待责任单位确认","完结-自动取消"
        },

        config_arr1: ["举报后，待责任单位确认", "待公司管理员确定责任单位", "责任单位确认", "责任单位确认", "责任单位确认",],
        config_arr2: ["责任单位确认", "责任申诉判决", "责任单位确认", "责任单位确认", "责任单位确认", "责任单位确认",],


        detial_style: "border: 2px solid rgb(73, 70, 70);",


        activeNames: [],
        current_status1: "",
        current_status2: [],
        current_btn: [],

        frock_number: "",
        baseUrl: "https://logisticsengineering.gree.com/container_manage_api/container_manage",
        list: [],
        detail_list: [],
        record_list: [],
        record_list1: [],
        record_list_total: 0,
        record_index: 1,
        record_show: false,
        page_size: 10,
        page: 1,
        total: 0,
        page_all: 0,
        all_total: 0,
        pan_total: 0,
        previewImageClick: false,
        show: false,
        show1: false,
        radio: null,
        radio1: null,
        data_arr: {},
        show2: false,
        show3: false,
        zgr_name: "",
        push_name: "",
        popup_show1: false,
        options1: [],
        status_show: true,
        reason: "",
        action_str: "",
        uploader: [],
        choose_img_btn_disabled: false,
        show4: false,
        show7: false,
        show11: false,
        show12: false,
        steps: [

        ],
        active: 0,
        radio11: null,
        radio22: null,
        show_ss: false,
        show33: false,
        record_show1: false,
        now_steps: {

        },
        disabled_status: false,
        required_status: false,
        photo_list: []
        // field_style: " background-color: #333333; color:white"
    },
    // 责任单位详情
    detailShow(e) {
        console.log(e.currentTarget.dataset.row_data);
        wx.showToast({
            title: e.currentTarget.dataset.row_data,
            icon: 'none'
        })
    },

    // 扫描查询工装车
    Submit() {
        let url = this.data.baseUrl + "/update_pan_frock"
        let data = {
            frock_number: this.data.frock_number,
            frock_name: this.data.frock_name,
        }
        this.post(url, data).then(res => {
            console.log("提交盘点", res)
            if (res.code == 20000) {
                this.searchData()
                wx.showToast({
                    title: res.msg,
                    icon: 'success'
                })
            } else {
                wx.showToast({
                    title: res.msg,
                    icon: 'error'
                })
            }
        }).catch(err => {
            wx.showToast({
                title: err.msg,
                icon: 'error'
            })
        })
    },
    // 查询按钮
    searchData() {
        let self = this;
        let url = self.data.baseUrl + "/query_pan_frock"
        let data = {
            page_size: self.data.page_size,
            page_num: self.data.page,
            frock_number: self.data.frock_number,
        }
        this.post(url, data).then(res => {
            if (res.code == 20000) {
                let show_list = res.data.data1
                let frock = show_list[0].frock_name
                self.setData({
                    list: show_list,
                    page_all: Math.ceil(res.data.total / self.data.page_size),
                    total: res.data.total,
                    all_total: res.data.all_total,
                    pan_total: res.data.pan_total,
                    frock_name: frock
                })

            } else {
                wx.showToast({
                    title: res.msg,
                    icon: "error"
                })
                self.setData({
                    list: [],
                })
            }
        }).catch(err => {
            self.setData({
                list: [],
            })
            wx.showToast({
                title: err.msg,
                icon: 'error'
            })
        })
    },
    // 分页
    onPageChange(e) {
        // console.log("xxx",e.detail.sonParam);
        let p = e.detail.sonParam
        this.setData({
            page: p,
        })
        this.getDataList()
    },

    // 获取数据
    getDataList() {
        let self = this;
        let url = self.data.baseUrl + "/get_involved_task"
        let data = {
            page_size: self.data.page_size,
            page: self.data.page,
        }
        this.post(url, data).then(res => {
            if (res.code == 20000) {
                let show_list = res.data.results
                let config_obj1 = self.data.config_obj
                let config_obj_ = self.data.config_obj_
                let reg = new RegExp("，", "g")
                let current_status = ""
                for (let i in show_list) {
                    show_list[i].submit_time = this.GMTToStr(show_list[i].submit_time)
                    current_status = show_list[i].status.replace(reg, "")
                    show_list[i].current_status1 = show_list[i].status.replace(reg, "")
                    show_list[i].current_status2 = config_obj1[show_list[i].current_status1]
                    show_list[i].current_btn = config_obj_[show_list[i].current_status1]
                    if (show_list[i].status == "举报后，待责任单位确认" || show_list[i].status == "公司管理员判定所属责任单位，待责任单位确认") {
                        show_list[i].show_btn = false
                    } else {
                        show_list[i].show_btn = true

                    }
                    let live_record_length = show_list[i].live_record.length
                    console.log("xxx", live_record_length);
                    show_list[i].time1 = this.GMTToStr(show_list[i].live_record[live_record_length - 1].time)
                }

                self.setData({
                    data_arr: show_list[0],
                    list: show_list,
                    page_all: Math.ceil(res.data.total / self.data.page_size),
                    total: res.data.total,
                    all_total: res.data.all_total,
                    pan_total: res.data.pan_total,
                    previewImageClick: true,
                    uploader: [],
                    reason: ""


                })
                // console.log("x", self.data.current_status1, self.data.current_status2, self.data.current_btn,);


            } else {
                wx.showToast({
                    title: res.msg,
                    icon: "error"
                })
                self.setData({
                    list: [],
                })
            }
        }).catch(err => {
            self.setData({
                list: [],
            })
            wx.showToast({
                title: err.msg,
                icon: 'error'
            })
        })
    },
    // 查看详情
    showDetail(e) {
        console.log(e.currentTarget.dataset.row_data);
        let row = e.currentTarget.dataset.row_data
        if (row.status == "公司管理员判定所属责任单位，待责任单位确认") {
            this.setData({
                disabled_status: true
            })
        }
        let list_ = []
        list_.push(row)
        let p_l = []
        for (let i in row.files) {
            let img_url = "https://logisticsengineering.gree.com/container_manage_api/container_manage/fs_download?file_id=" + row.files[i]
            p_l.push(img_url)
        }
        this.setData({
            detail_list: list_,
            show: true,
            photo_list: p_l,
            data_arr: row
        })
    },
    // 操作记录框关闭
    onClose6() {
        this.setData({
            record_show: false,
            record_index: 1,
            reason: "",
            uploader: []
        })
    },

    // 查看操作记录
    recordShow(e) {
        this.setData({
            activeNames: e.detail,
        });
        console.log("123123", this.data.data_arr);

        let live_record1 = this.data.data_arr.live_record
        for (let i in live_record1) {
            live_record1[i].time = this.GMTToStr(live_record1[i].time)
        }
        let step = []
        for (let i in live_record1) {
            let obj = {
                // text: live_record1[i].action,
                desc: live_record1[i].involved_name + "，" + live_record1[i].time + "，" + live_record1[i].action,
                detail: live_record1[i]
            }
            step.push(obj)
        }

        for (let i in step) {
            console.log("12313", step[i].action);
            if (step[i].detail.action == "问题提交" || step[i].detail.action == "第1次整改完成，举报人不认可，待重新整改" || step[i].detail.action == "待公司管理员确认是否考核") {
                step[i].desc = "举报人," + step[i].detail.time + "，" + step[i].detail.action

            }
        }

        this.setData({
            // record_show: true,
            steps: step,
            active: live_record1.length - 1

        })


    },
    // 点击记录步骤
    showStep(e) {
        console.log("1", this.data.steps[e.detail].detail);

        this.setData({
            now_steps: this.data.steps[e.detail].detail,
            record_show1: true
        })

    },
    // 是否本单位责任选框
    onChange11(event) {
        console.log(event.detail);
        this.setData({
            radio11: event.detail
        })
        if (event.detail == 2) {
            this.setData({

                show_ss: true,
                show33: false,
                show2: false,
                reason: ""
            })
        } else if (event.detail == 1) {
            this.confirmBtn()
            this.setData({
                show_ss: false,
                // show2: true,
                reason: ""

            })
        }

    },

    // 是否整改
    onChange22(event) {
        console.log(event.detail);
        this.setData({
            radio22: event.detail
        })
        if (event.detail == 1) {
            this.setData({
                show33: true,
            })
        } else if (event.detail == 2) {
            this.setData({
                show33: false,
            })
        }

    },
    // 处理对话框关闭
    onClose() {
        this.setData({
            show: false,
            reason: "",
            radio11: null,
            radio22: null,
            data_arr: "",
            show_ss: false,
            show2: false,
            disabled_status: false,
            activeNames: [],

        })
    },
    // 处理对话框点确认
    onConfirm() {
        // 1.判断是否申诉
        if (this.data.radio11 == 2) {
            console.log("申诉");
            // 判断说明是否填写
            if (!this.data.reason) {
                wx.showToast({
                    title: '请填写申诉说明！',
                    icon: 'error'
                })
            } else {
                let row = this.data.data_arr
                console.log("当前操作数据", row);
                if (row.status) {

                }
                let args1 = []
                if (row.live_record.length < 2) {
                    args1 = []
                } else {
                    args1 = row.live_record[1].args

                }
                let self = this;
                let url = self.data.baseUrl + "/update_problem"
                let data = {
                    key: row.key,
                    company: row.company,
                    status: row.status,
                    res_accurate: row.res_accurate,
                    submitter: row.submitter,
                    action: "待公司管理员确定责任单位",
                    reason: self.data.reason,
                    args: args1,
                    files: [],
                }
                this.post(url, data).then(res => {
                    if (res.code == 20000) {
                        self.setData({
                            page_size: 10,
                            Page: 1
                        })
                        this.getDataList()
                        wx.showToast({
                            title: res.msg,
                        })
                    } else {
                        wx.showToast({
                            title: res.msg,
                            icon: "error"
                        })
                    }
                }).catch(err => {
                    wx.showToast({
                        title: err.msg,
                        icon: 'error'
                    })
                })


            }

        }
    },
 // 预览照片
 previewPhoto1(e) {
    let img_url = "https://logisticsengineering.gree.com/container_manage_api/container_manage/fs_download?file_id=" + e.currentTarget.dataset.row_data
    console.log(img_url);
    let p_l = []

    for (let i in this.data.now_steps.files) {
        let img_url = "https://logisticsengineering.gree.com/container_manage_api/container_manage/fs_download?file_id=" + this.data.now_steps.files[i]
        p_l.push(img_url)
    }

    wx.previewImage({
        current: img_url,
        urls: p_l,
    })
},

    // 预览照片
    previewPhoto(e) {
        let img_url = "https://logisticsengineering.gree.com/container_manage_api/container_manage/fs_download?file_id=" + e.currentTarget.dataset.row_data
        console.log(img_url);


        let l = this.data.photo_list
        wx.previewImage({
            current: img_url,
            urls: l,
        })
    },
    // 说明情况/照片框弹出关闭
    onClose4() {
        this.setData({
            show4: false,
            required_status: false,

            uploader: [],
            reason: []
        })
    },

    // 说明情况/照片框弹出
    actionBtnShow(e) {
        console.log("1123", this.data.data_arr);
        console.log(e.currentTarget.dataset.row_data);
        if (e.currentTarget.dataset.row_data == "整改报完工") {
            this.setData({
                required_status: true,
            })
        }

        let row = this.data.data_arr
        let index = row.current_btn.indexOf(e.currentTarget.dataset.row_data)
        let action_str = row.current_status2[index]
        this.setData({
            action_str: action_str
        })
        console.log("传过去的字符串", action_str);
        if (action_str == "责任单位已确认，待整改" || action_str == "责任单位已确认，待第2次整改") {
            this.confirmBtn()

        } else {
            this.setData({
                show4: true
            })
            // this.action(action_str)

        }


    },

    // 操作按钮函数
    action() {
        const uploader = [...this.data.uploader];
        uploader.forEach((element, index) => {
            uploader[index] = element.url.split("=")[1];
        })
        console.log("整改/说明照片", uploader);
        let row = this.data.data_arr
        console.log("当前操作数据", row);
        let args1 = []
        if (row.live_record.length < 2) {
            args1 = []
        } else {
            args1 = row.live_record[1].args

        }
        if (this.data.reason == "") {
            wx.showToast({
                title: '请填写说明情况！',
                icon: 'error'
            })
        } else {
            if (this.data.action_str == "第2次整改完成，待举报人确认" || this.data.action_str == "第1次整改完成，待举报人确认") {
                if (uploader.length == 0) {
                    console.log("asdasd");
                    wx.showToast({
                        title: '请上传照片！',
                        icon: 'error'
                    })
                } else {
                    let self = this;
                    let url = self.data.baseUrl + "/update_problem"
                    let data = {
                        key: row.key,
                        company: row.company,
                        status: row.status,
                        res_accurate: row.res_accurate,
                        submitter: row.submitter,
                        action: self.data.action_str,
                        reason: self.data.reason,
                        args: args1,
                        files: uploader,
                    }
                    this.post(url, data).then(res => {
                        if (res.code == 20000) {
                            self.setData({
                                page_size: 10,
                                Page: 1,
                                show: false
                            })
                            this.getDataList()
                            wx.showToast({
                                title: res.msg,
                            })
                        } else {
                            wx.showToast({
                                title: res.msg,
                                icon: "error"
                            })
                        }
                    }).catch(err => {
                        wx.showToast({
                            title: err.msg,
                            icon: 'error'
                        })
                    })
                }
            } else {
                let self = this;
                let url = self.data.baseUrl + "/update_problem"
                let data = {
                    key: row.key,
                    company: row.company,
                    status: row.status,
                    res_accurate: row.res_accurate,
                    submitter: row.submitter,
                    action: self.data.action_str,
                    reason: self.data.reason,
                    args: args1,
                    files: uploader,
                }
                this.post(url, data).then(res => {
                    if (res.code == 20000) {
                        self.setData({
                            page_size: 10,
                            Page: 1,
                            show: false
                        })
                        this.getDataList()
                        wx.showToast({
                            title: res.msg,
                        })
                    } else {
                        wx.showToast({
                            title: res.msg,
                            icon: "error"
                        })
                    }
                }).catch(err => {
                    wx.showToast({
                        title: err.msg,
                        icon: 'error'
                    })
                })


            }


        }


    },

    // 申诉
    action1() {
        this.setData({
            show7: true
        })
    },

    // 点击确定按钮弹出对话框
    confirmBtn() {
        this.setData({
            radio: null,
            show1: true
        })
    },
    // 是否整改选择框
    onChange(event) {
        console.log(event.detail);
        this.setData({
            radio: event.detail,
        });
        if (event.detail == 1) {
            this.setData({
                show2: true,
                radio1: null
            })
        } else {
            this.setData({
                show2: false
            })
        }
    },

    // 是否转发其他人整改对话框
    onChange1(event) {
        console.log("11", event.detail);
        this.setData({
            radio1: event.detail,
        });
        if (event.detail == 2) {
            let submitter = this.data.data_arr.submitter
            this.setData({
                show3: false,
                zgr_name: submitter
            })
            console.log("cc", this.data.zgr_name);
        } else {
            this.setData({
                zgr_name: "",
                show3: true,
            })
        }
    },

    // 通过名称查推荐人
    getPushUsers() {
        let self = this;
        let url = self.data.baseUrl + "/get_push_users"
        let data = {
            name: self.data.zgr_name,

        }
        this.post(url, data).then(res => {
            if (res.code == 20000) {
                let list_ = res.data
                self.setData({
                    options1: list_
                })
                // wx.showToast({
                //   title: res.msg,
                // })

            } else {
                wx.showToast({
                    title: res.msg,
                    icon: "error"
                })

            }
        }).catch(err => {

            wx.showToast({
                title: err.msg,
                icon: 'error'
            })
        })
    },
    // 点击--确定推进人--输入框
    onClick1(event) {
        // event.detail 为当前输入的值
        // console.log(event.detail);
        this.setData({
            popup_show1: true
        })
    },
    // 选择--确定推进人--输入框关闭
    onClose1() {
        this.setData({ popup_show1: false });
    },
    // 确定推进人
    onradioChange2(e) {
        console.log(e.detail);
        this.setData({
            zgr_name: e.detail,
            popup_show1: false

        })
    },
    // 是否整改对话框关闭
    onClose2() {
        this.setData({
            show1: false,
            show2: false,
            show3: false,
            radio1: null,
            uploader: [],
            reason: [],
            radio11: null


        })
    },
    // 整改方法函数
    onConfirm1() {
        console.log("Xxx", this.data.radio);
        const uploader = [...this.data.uploader];
        uploader.forEach((element, index) => {
            uploader[index] = element.url.split("=")[1];
        })

        console.log("整改/说明照片", uploader);

        wx.showLoading({
            title: 'Loading。。。',
        })
        let key = this.data.radio
        let row = this.data.data_arr
        console.log("当前操作数据", row);
        if (this.data.reason == "") {
            wx.showToast({
                title: '请填写说明情况',
                icon: 'error'
            })

        } else {
            if (this.data.radio != null) {
                if (key == 2) {
                    console.log("整改框选“否”");
                    let self = this;
                    let url = self.data.baseUrl + "/update_problem"

                    let data = {
                        key: row.key,
                        company: row.company,
                        status: row.status,
                        res_accurate: row.res_accurate,
                        submitter: row.submitter,
                        action: "完结-责任单位已确认，作为月度考评数据",
                        reason: self.data.reason,
                        args: [],
                        files: uploader,
                    }
                    this.post(url, data).then(res => {
                        if (res.code == 20000) {
                            wx.hideLoading();
                            self.setData({
                                page_size: 10,
                                Page: 1,
                                show: false
                            })
                            this.getDataList()
                            wx.showToast({
                                title: res.msg,
                            })
                        } else {
                            wx.hideLoading();
                            wx.showToast({
                                title: res.msg,
                                icon: "error"
                            })
                        }
                    }).catch(err => {
                        wx.hideLoading();
                        wx.showToast({
                            title: err.msg,
                            icon: 'error'
                        })
                    })

                } else {
                    console.log("整改框选“是”");
                    let self = this;
                    let action1 = self.data.action_str
                    if (row.status == "举报后，待责任单位确认") {
                        action1 = "责任单位已确认，待整改"

                    }
                    let url = self.data.baseUrl + "/update_problem"
                    let args1 = []
                    args1.push(self.data.zgr_name)
                    let data = {
                        key: row.key,
                        company: row.company,
                        status: row.status,
                        res_accurate: row.res_accurate,
                        submitter: row.submitter,
                        action: action1,
                        reason: self.data.reason,
                        args: args1,
                        files: uploader,
                    }
                    this.post(url, data).then(res => {
                        if (res.code == 20000) {
                            self.setData({
                                page_size: 10,
                                Page: 1,
                                show: false

                            })
                            this.getDataList()
                            wx.showToast({
                                title: res.msg,
                            })
                        } else {
                            wx.showToast({
                                title: res.msg,
                                icon: "error"
                            })
                        }
                    }).catch(err => {
                        wx.showToast({
                            title: err.msg,
                            icon: 'error'
                        })
                    })
                }
            } else {
                wx.showToast({
                    title: '请选择是否整改！',
                    icon: 'error'
                })

            }

        }

    },
    // 整改报完工
    bwgBtn() {
        let row = this.data.data_arr
        console.log("当前操作数据", row);
        console.log("整改报完工");
        let self = this;
        let url = self.data.baseUrl + "/update_problem"
        let data = {
            key: row.key,
            company: row.company,
            status: row.status,
            res_accurate: row.res_accurate,
            submitter: row.submitter,
            action: "第1次整改完成，待举报人确认",
            reason: "",
            args: row.live_record[1].args,
            files: row.files,
        }
        this.post(url, data).then(res => {
            if (res.code == 20000) {
                self.setData({
                    page_size: 10,
                    Page: 1
                })
                this.getDataList()
                wx.showToast({
                    title: res.msg,
                })
            } else {
                wx.showToast({
                    title: res.msg,
                    icon: "error"
                })
            }
        }).catch(err => {
            wx.showToast({
                title: err.msg,
                icon: 'error'
            })
        })

    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {

    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {
        if (this.data.previewImageClick == false) {
            this.getDataList()

        }

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    },

    // 照片选取
    try_upload(e) {
        const self = this;
        // 关闭照片选取
        self.setData({
            choose_img_btn_disabled: true
        });
        // 确定还有张图片可以选择
        const count = 3 - this.data.uploader.length;
        wx.chooseMedia({
            count: count,
            mediaType: ['image'],
            sourceType: ['album', 'camera'],
            maxDuration: 30,
            camera: 'back',
            success(res) {
                const myUploadFiles = res.tempFiles.map(tempFile => {
                    const tempFilePath = tempFile.tempFilePath;
                    return self.myUploadFile(tempFilePath);
                });
                wx.showLoading({
                    title: '开始上传。。。',
                })
                Promise.all(myUploadFiles).then(file_ids => {
                    wx.hideLoading();
                    // 处理UI
                    console.log(file_ids);
                    const uploader = self.data.uploader;
                    const new_uploader = uploader.concat(file_ids.map(file_id => {
                        return {
                            url: baseUrl + "fs_download?file_id=" + file_id,
                            isImage: true
                        };
                    }));
                    self.setData({
                        uploader: new_uploader
                    })
                    if (self.data.uploader.length < 3) {
                        self.setData({
                            choose_img_btn_disabled: false
                        });
                    }
                    wx.showToast({
                        title: '上传成功！',
                    });

                }).catch(msg => {
                    wx.hideLoading();
                    if (self.data.uploader.length < 3) {
                        self.setData({
                            choose_img_btn_disabled: false
                        })
                    }
                    wx.showToast({
                        title: msg,
                        icon: "error"
                    })
                    console.log(msg);
                });
            },
            fail() {
                if (self.data.uploader.length < 3) {
                    self.setData({
                        choose_img_btn_disabled: false
                    })
                }
            }
        })
    },
    myUploadFile(file) {
        return new Promise((resolve, reject) => {
            wx.uploadFile({
                url: "https://logisticsengineering.gree.com/container_manage_api/container_manage/fs_upload",
                filePath: file,
                name: 'file',
                formData: {},
                success(res) {
                    const result = JSON.parse(res.data);
                    console.log(result);
                    wx.hideLoading();
                    if (result.code == 20000) {
                        resolve(result.data.file_id);
                    } else {
                        reject(msg);
                    }

                },
                fail() {
                    reject("未知错误446");
                }
            })
        });
    },
    handle_delete(e) {
        const index = e.detail.index;
        const file = this.data.uploader[index];
        const file_id = file.url.split("=")[1];
        const uploader = this.data.uploader;
        const self = this;
        this.post(baseUrl + 'fs_delete', { file_id }).then((res) => {
            const code = res["code"];
            if (code == 20000) {
                uploader.splice(index, 1);
                self.setData({
                    choose_img_btn_disabled: false
                })
                console.log("uploader", uploader)
                self.setData({
                    uploader
                });
            } else {
                wx.showToast({
                    title: result.msg,
                    icon: "error"
                })
            }
        }).catch(() => {
            console.log("error");
        })
    },
})